package com.jjz.id.config;

import com.jjz.id.config.properties.JueCorsProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

/**
 * @author ZJL
 * @create 2025-05-27-16:58
 */

public class CorsConfiguration {
    @Primary
    @Bean
    public CorsConfigurationSource corsConfigurationSource(JueCorsProperties corsProperties) {
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        org.springframework.web.cors.CorsConfiguration config = corsProperties.toCorsConfiguration();
        source.registerCorsConfiguration("/**", config);
        return source;
    }
}
